@extends('layouts.app')
@section('title')
    用户 - {{$user->name}} 的个人信息
@endsection

@section('content')
    <div class="fix-top-bar"></div>
    <div class="container main-container m-t-100" style="min-height: 788px">
        <div class="users-show row font">
            <div class="col-md-3">
                <div class="box">
                    <div class="padding-sm user-basic-info">
                        <div>
                            <div class="media">
                                <div class="media-body">
                                    <div class="col-lg-4 pull-left p-0">
                                        <a class="popover-with-html" href="{{url('/user/edit/avatar')}}">
                                            <img class="media-object avatar-112 avatar img-thumbnail"  src="{{cdn($user->profile)}}">
                                        </a>
                                        @if (!empty($user->userRole()->first()))
                                            <div class="col-lg-12" style=" height: 30px">
                                                <div style="width: 80px;height: 30px; margin: 0 auto;margin-top: 5px">
                                                    <button class="btn btn-success btn-xs">{{$user->userRole()->first()->role()->first()->display_name}}</button>
                                                </div>
                                            </div>
                                        @endif
                                    </div>
                                    <div class="col-md-8 pull-right m-t-20">
                                        <h3 class="media-heading">{{$user->name}}</h3>
                                        <div class="item"></div>
                                        <div class="item">第 {{$user->registerIndex()}} 位会员</div>
                                        <div class="item number">
                                            注册于 <span class="timeago popover-with-html" data-content="{{$user->created_at}}" data-original-title="" title="">{{dateTimeC($user->created_at)}}前</span>
                                        </div>
                                        <div class="item number">
                                            活跃于 <span class="timeago popover-with-html" data-content="{{$user->lastActivedAt()}}" data-original-title="" title="">{{dateTimeC($user->lastActivedAt())}}前</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <hr>
                        <div class="follow-info row">
                            <div class="col-xs-4">
                                <a class="counter" href="#">0</a>
                                <a class="text" href="#">关注者</a>
                            </div>
                            <div class="col-xs-4">
                                <a class="counter" href="#">0</a>
                                <a class="text" href="#">评论</a>
                            </div>
                            <div class="col-xs-4">
                                <a class="counter" href="#">0</a>
                                <a class="text" href="#">话题</a>
                            </div>
                        </div>
                        <hr>
                        <div class="topic-author-box text-center col-md-12">
                            @include('include.user.userType')
                        </div>
                        <hr class="m-t-10 m-b-10">
                        @if (Auth::user()->id != $user->id)
                            <a data-method="post" class="btn btn-warning btn-block btn-lg" href="javascript:void(0);"  style="cursor:pointer;">
                                <i class="fa fa-plus"></i> 关注
                            </a>
                        @else
                            <a class="btn btn-primary btn-block btn-lg" href="{{url('/user/edit')}}" id="user-edit-button">
                                <i class="fa fa-edit"></i> 编辑个人资料
                            </a>
                        @endif
                        @if (Auth::user()->roleFlag() & \App\other\AdminFlag::ADMIN_FLAG_USER)
                            <hr class="m-t-10 m-b-10">
                            <a class="btn btn-danger btn-block btn-lg" href="{{url('/admin/user/edit?id='.$user->id)}}">
                                <i class="fa fa-edit"></i> 编辑此用户
                            </a>
                        @endif
                    </div>
                </div>
                <div class="box text-center">
                    <div class="padding-sm user-basic-nav">
                        <ul class="list-group list-ac">
                            <a href="#">
                                <li class="list-group-item" style="border-radius: 0;">
                                    <i class="text-md fa fa-list-ul"></i> Ta 发布的话题
                                </li>
                            </a>

                            <a href="#" class="">
                                <li class="list-group-item" style="border-radius: 0;">
                                    <i class="text-md fa fa-comment"></i> Ta 发表的回复</li>
                            </a>

                            <a href="#" class="">
                                <li class="list-group-item" style="border-radius: 0;">
                                    <i class="text-md fa fa-eye"></i> Ta 关注的用户</li>
                            </a>

                            <a href="#" class="">
                                <li class="list-group-item" style="border-radius: 0;">
                                    <i class="text-md fa fa-thumbs-up"></i> Ta 赞过的话题</li>
                            </a>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="main-col col-md-9 left-col">
                <div class="box text-center">{{$user->introduction or ''}}</div>
                <div class="panel panel-inverse">
                    <div class="panel-heading">
                        最近话题
                    </div>
                    <div class="panel-body">
                        @if (empty($topics))
                            <div class="empty-block">没有任何数据~~</div>
                        @else
                            <ul class="list-group m-b-0">
                                @foreach($topics as $topic)
                            <li class="list-group-item border-none" style="padding-bottom: 1px;padding-top: 10px">
                                <a href="{{url('/forum/topic')}}/{{$topic->id or 0}}" title="{{$topic->title or ''}}">
                                    <span style="color: {{$topic->categorie->color or ''}}">[{{$topic->categorie->name or ''}}]</span> {{$topic->title or ''}}
                                </a>
                                <span class="meta">
                                    <a href="{{url('/forum/plate/')}}/{{$topic->partition->id or 0}}" style="color: #d0d0d0;">{{$topic->partition->title or ''}}</a>
                                    <span> ⋅ </span>{{count($topic->vote()->get())}} 点赞
                                    <span> ⋅ </span>{{$topic->reply_count or 0}} 回复
                                    <span> ⋅ </span>
                                    <span class="timeago popover-with-html" data-content="{{$topic->created_at or ''}}">{{dateTimeC($topic->created_at)}}前</span>
                                </span>
                                <hr class="m-b-0 m-t-5">
                            </li>
                                @endforeach
                            </ul>
                        @endif
                    </div>
                </div>

                <div class="panel panel-inverse">
                    <div class="panel-heading">
                        最新评论
                    </div>
                    <div class="panel-body">
                        @if (empty($replies))
                            <div class="empty-block">还未留下任何评论~~</div>
                        @else
                            <ul class="list-group m-b-0">
                                @foreach($replies as $reply)
                                <li class="list-group-item border-none">
                                    <a href="{{url('/forum/topic/')}}/{{$reply->topic->id or 0}}#reply{{$reply->index or 0}}" title="{{$reply->topic->title or ''}}" class="remove-padding-left">
                                        {{$reply->topic->title or ''}}
                                    </a>
                                    <span class="meta"> at <span class="timeago popover-with-html" title=""
                                                                 data-content="{{$reply->created_at}}">{{dateTimeC($reply->created_at)}}前</span></span>

                                    <div class="reply-body markdown-reply content-body">
                                        {{toMakeed_Html($reply->body)}}
                                    </div>
                                    <hr class="m-b-0">
                                </li>
                                @endforeach
                            </ul>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="w100 pull-left m-t-10" style="background-color:  white">
        @include('include.bottom.info')
    </div>
@endsection

@section('js')
    <script>
        var body = $(document.body);
        $(document).ready(function () {
            body.css("background-color", "whitesmoke");
            body.css("height", "10px");
            $('.popover-with-html').hover(function () {
                $('.popover-with-html').popover({
                    html : true,
                    trigger : 'hover',
                    container: 'body',
                    placement: 'auto top'
                });
            });
        })
    </script>
@endsection